<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

  <title>My JSP 'courseAll.jsp' starting page</title>

  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  <!--
  <link rel="stylesheet" type="text/css" href="styles.css">
  -->
  <link rel="stylesheet" href="css/bootstrap.min.css">
  <style type="text/css">
    .div_list {
      width: 75%;
      margin: 0 auto;
      margin-top: 50px;
      margin-left: 20%;

    }
    #tableClass{
      margin:0 auto;
      width: 100%

    }
    .form1{
      width: 200px;
      display: inline-block
    }
    font {
      color: red;
      font-weight: bold;
      text-align: center;
    }
    table{
      margin:0 auto;

    }
    table tr td{
      text-align: center;
      width:150px;
      height:40px;
    }
    a{
      text-decoration: none;
      cursor:pointer;
    }
  </style>
  <script src="${pageContext.request.contextPath}/js/jquery-1.11.1.min.js"></script>
  <script type="text/JavaScript">
    //分页
    function getPage(page){
      //1.把page设置到查询表单的隐藏域
      $("#page").val(page);
      //2.获取表单对象提交
      $("#myForm").submit();
    }
  </script>
</head>

<body>
<h4 align="center">
  <form action="${pageContext.request.contextPath}/ServletFindAllBorrow" method="post" id="myForm">

    <!--编写一个当前页的隐藏域  -->
    <input type="hidden" name="page" id="page" value="1">
  </form>
</h4>
  <div class="div_list panel panel-default">
    <div class="panel-heading">借阅信息</div>
    <table class="table panel-body" id="tableClass">
      <tr>
        <td>图书编号</td>
        <td>图书图片</td>
        <td>图书名称</td>
        <td>借书日期</td>
        <td>还书时间</td>
        <td>状态</td>
        <td>操作</td>
      </tr>
      <c:forEach var="list" items="${pageUtil.list}">
        <tr>
          <td>
              ${list.getBook().getBid() }
            <input type="hidden" name="ubid" value="${list.getUbid()}">
          </td>
          <td>
            <img src="${pageContext.request.contextPath}/upload/${list.getBook().getImgurl()==null?"ts.jpeg":list.getBook().getImgurl()}" width="50px">
          </td>
          <td>${list.getBook().getBname()}</td>
          <td>${list.getBbooksdate()}</td>
          <td>${list.getRbookdate()}</td>
          <td>${list.getUbstate()==1?"未还":"已还"}</td>
          <td>
            <c:choose>
              <c:when test="${list.getUbstate()==1}">
                <a href="ServletReturnBook?ubid=${list.ubid}&bid=${list.book.bid}" onclick="return confirm('是否确认还书？')">还书</a>
              </c:when>
              <c:otherwise>
              </c:otherwise>
            </c:choose>

           </td>

        </tr>
      </c:forEach>
      <tr>
        <td colspan="7">总记录数：${pageUtil.totalCount}
          当前页/总页数：${pageUtil.currentPage}/${pageUtil.totalPages} &nbsp;&nbsp;&nbsp;
          <a href="#" onclick="getPage(1)">首页</a>
          <a href="#" onclick="getPage(${pageUtil.prevPage })">上一页</a>
          <a href="#" onclick="getPage(${pageUtil.nextPage })">下一页</a>
          <a href="#" onclick="getPage(${pageUtil.totalPages })">尾页</a>
        </td>
      </tr>
    </table>
  </div>
</body>
</html>
